{include file='public/header' /}


<body>

    <div class="layui-fluid">

        <div class="layui-row">

            <form class="layui-form " enctype="multipart/form-data" id="file" style="margin: 50px;">


                <div class="layui-form-item">

                    <label class="layui-form-label" for="name">

                        <span class="x-red">

                            *

                        </span>

                        登录账号

                    </label>

                    <div class="layui-input-block ">

                        <input autocomplete="off" class="layui-input" id="account" lay-verify="required" name="account" placeholder="请输入登录账号" required="" type="text">
                    </div>

                </div>



                 <div class="layui-form-item">

                    <label class="layui-form-label" for="name">

                        <span class="x-red">

                            *

                        </span>

                        登录密码

                    </label>

                    <div class="layui-input-block ">

                        <input autocomplete="off" class="layui-input" id="password" lay-verify="required" name="password" placeholder="请输入登录密码" required="" type="password">
                    </div>

                </div>




                <div class="layui-form-item">
                  <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>
                        管理员类型
                    </label>

                    <div class="layui-input-block">
                      <input type="radio" name="type" value="2" title="普通管理员" checked="" lay-filter="projectFilter">
                      <input type="radio" name="type" value="1" title="超级管理员" lay-filter="projectFilter">

                    </div>
                   
                </div>



                <div class="layui-form-item" id="quanxian">
                    <label class="layui-form-label" for="username">
                        分配角色
                    </label>
                    <div class="layui-input-block">

                        <select name="role_id">
                            {foreach $rolelist as $v}
                                <option value="{$v.id}">{$v.name}</option>
                            {/foreach}
                
                        </select>

                    </div>
                </div>


              
                <div class="layui-form-item" style="margin-top: 50px;">

                    <label class="layui-form-label" for="L_repass">

                    </label>

                    <button class="layui-btn" id="submitBtn" lay-filter="add" lay-submit="" type="submit">

                        添加管理员

                    </button>

                </div>

            </form>

        </div>

    </div>


    <script>
          layui.use(['form', 'jquery'], function(){
            var form = layui.form;
            form.on("radio(projectFilter)", function (data) {
                if (this.value == '1') { 
                    $('#quanxian').hide();
                }else if(this.value == '2'){ 
                    $('#quanxian').show();
                }
            });

            });
      
     </script>




    <script>

        layui.use(['form', 'layer'],

    function() {

        $ = layui.jquery;

        var form = layui.form,

        layer = layui.layer;


    });

    </script>






    <script>

    layui.config({
        base: '__ROOT__/static/admin/lib/layui/lay/modules/',
    })
    // 只需要引入multiSelect模块即可
    layui.use(['multiSelect'],function() {
        
    });
        //获取form表单的节点

  fileEle = document.getElementById('file');

  arr = [];

  //把value的值拿出来

  valEle = '';

  nulEle = '';





  $("#file").on("submit",function(){

   

    //阻止form默认提交

    var evt = event;

    evt.preventDefault();

    

    //得到formData

    var formData = new FormData($(this)[0]);


   // $("#submitBtn").attr("disabled","disabled");


    $.ajax({

      url:"{:url('Cadmin/addgood')}",

      type:"post",

      async: false,

      cache: false,

      contentType: false,

      processData: false,

      data:formData,

      success:function(data){

        console.log(data);

        if (data == 1) {

            layer.msg('添加成功', {icon: 1,time: 1500});

            setTimeout(function(){
              //刷新父页面
              window.parent.location.reload(); 
              // 获得frame索引
              var index = parent.layer.getFrameIndex(window.name); 
              //关闭当前frame
              parent.layer.close(index);

            },1500);

        }else{

            layer.msg('添加失败', {icon: 2,time: 1500});


        }
        

      }

    })

  })

    </script>

</body>

